package com.tg.data.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.tange.base.toolkit.StringUtils;

import java.util.ArrayList;
import java.util.List;

import io.objectbox.annotation.Entity;
import io.objectbox.annotation.Id;

@Entity
public class TrackBean implements Parcelable {
    @Id
    public long id;//设备ID
    public String uuid;//设备uuid
    public int act;
    public int track_no;
    public int n_psp;
    public String name;
    public String prePosition = "";
    public int track = 0;


    public List<Integer> getPrePosition() {
        List<Integer> list = new ArrayList<>();
        if (!StringUtils.isEmpty(prePosition)){
            String[] strArr = prePosition.split(",");
            for (int i = 0; i < strArr.length; i++){
                list.add(Integer.valueOf(strArr[i]));
            }
        }

        return list;
    }

    public TrackBean(){
        n_psp = 0;
        prePosition = "";
    }

    protected TrackBean(Parcel in) {
        id = in.readLong();
        uuid = in.readString();
        act = in.readInt();
        track_no = in.readInt();
        n_psp = in.readInt();
        name = in.readString();
        prePosition = in.readString();
        track = in.readInt();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(id);
        dest.writeString(uuid);
        dest.writeInt(act);
        dest.writeInt(track_no);
        dest.writeInt(n_psp);
        dest.writeString(name);
        dest.writeString(prePosition);
        dest.writeInt(track);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<TrackBean> CREATOR = new Creator<TrackBean>() {
        @Override
        public TrackBean createFromParcel(Parcel in) {
            return new TrackBean(in);
        }

        @Override
        public TrackBean[] newArray(int size) {
            return new TrackBean[size];
        }
    };
}
